home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / appkit / NXSpellChecker.h < prev    next >
Text File  |  1992-03-02  |  5KB  |  118 lines

  1. #import <objc/Object.h>
  2. #import "readOnlyTextStream.h"
  3.  
  4. /*
  5. The spell-checking functionality can only be performed on text streams which respond to the NXReadOnlyTextStream protocol and to the NXSelectText protocol for dealing with a selection in the text stream on screen (since spell-checking is a necessarily interactive mechanism).
  6. */
  7.  
  8. @protocol NXSelectText
  9. - (void)selectCharactersFrom:(int)start to:(int)end;
  10. - (int)selectionCharacterCount;
  11. - (int)readCharactersFromSelection:(char *)buffer count:(int)count;
  12. - (void)makeSelectionVisible;
  13. @end
  14.  
  15. /*
  16. Text streams can optionally respond to this method if they want to support not only spell-checking, but spell correction.  This message is sent down the responder chain.  The receiver should ask the sender for its selectedCell's stringValue (the correct spelling of the word) and replace its selection if appropriate.
  17. */
  18.  
  19. @protocol NXChangeSpelling
  20. - changeSpelling:sender;
  21. @end
  22.  
  23. /*
  24. If a document responds to this protocol, then the Ignore button will work in the spell checking panel.  This method must return a unique integer specific to the document.  This identifier can be used with the *ForSpellDocument: methods.  A tag of ZERO is illegal.  If you don't want your document to be able to have document-specific ignored words, then don't implement this method.
  25. */
  26.  
  27. @protocol NXIgnoreMisspelledWords
  28. - (int)spellDocumentTag;
  29. @end
  30.  
  31. /*
  32. The NXSpellChecker object is used by a client (e.g. a document in an application) to spell-check a given NXReadOnlyTextStream (a protocol which makes the text in a document available to other objects via a series of methods).  There is only one NXSpellChecker instance per application (since spell-checking is interactive and you only have one mouse and one keyboard).
  33.  
  34. The textStream being spell-checked need only be valid for the duration of the call to checkSpelling:of:.  At the start of checkSpelling:of:, the currentCharacterOffset should be equal to the start of the current selection in the text (or the insertion point or the start of the text if there is no selection or insertion point).
  35.  
  36. The usual usage of this is to implement a checkSpelling: method in an object that responds to the NXReadOnlyTextStream and NXSelectText protocols, then, upon receiving checkSpelling:, the NXReadOnlyTextStream object calls [[NXSpellChecker sharedInstance] checkSpelling:mode of:self].
  37. */
  38.  
  39. typedef enum {
  40.     NX_CheckSpelling,
  41.     NX_CheckSpellingToEnd,
  42.     NX_CheckSpellingFromStart,
  43.     NX_CheckSpellingInSelection,
  44.     NX_CountWords,
  45.     NX_CountWordsToEnd,
  46.     NX_CountWordsInSelection
  47. } NXSpellCheckMode;
  48.  
  49. @interface NXSpellChecker : Object
  50. {
  51. @private        /* these are private and are */
  52.     id serverHashTable;    /* subject to change in any future */
  53.     id realTextStream;    /* release, so don't access them! */
  54.     id spellController;
  55.     id guessesBrowser;
  56.     id wordField;
  57.     id languagePopUp;
  58.     id guessesList;
  59.     id panel;
  60.     id checkers;
  61.     id userDictionaries;
  62.     id correctButton;
  63.     id guessButton;
  64.     id ignoreButton;
  65.     id accessoryView;
  66.     int startOffset;
  67.     int selectionOffset;
  68.     int selectionSize;
  69.     id dictionaryBrowser;
  70.     char *selectionBuffer;
  71.     void *_spellServers;
  72.     char *lastGuess;
  73.     BOOL autoShowGuessPanel;
  74.     BOOL needDelayedGuess;
  75.     BOOL haveUsed;
  76.     BOOL reserved3;
  77.     id deleteButton;
  78.     id openButton;
  79.     id learnButton;
  80.     id forgetButton;
  81.     void *reserved;
  82. }
  83.  
  84. /* Only one per application. */
  85.  
  86. + sharedInstance;
  87. + sharedInstance:(BOOL)create;
  88.  
  89. /* Initiates a spell-check of the text in textStream.  Returns whether a misspelling was found. */
  90.  
  91. - (BOOL)checkSpelling:(NXSpellCheckMode)mode of:(id <NXReadOnlyTextStream, NXSelectText>)textStream;
  92. - (BOOL)checkSpelling:(NXSpellCheckMode)mode
  93.            of:(id <NXReadOnlyTextStream, NXSelectText>)textStream
  94.         wordCount:(int *)wordCount;
  95.  
  96. /* Sets and gets attributes of the spell-correction panel. */
  97.  
  98. - spellingPanel;
  99. - accessoryView;
  100. - setAccessoryView:aView;
  101.  
  102. /* Ignored words.  The caller owns the return value from get and should free it.  When a document closes, it should notify the NXSpellChecker via closeSpellDocumentWithTag: so that its ignored word list gets cleaned up. */
  103.  
  104. - (char **)ignoredWordsForSpellDocument:(int)tag;
  105. - setIgnoredWords:(const char *const *)words forSpellDocument:(int)tag;
  106. - closeSpellDocument:(int)tag;
  107.  
  108. /* Allows programmatic setting of the language to spell-check in (normally chosen by a pop-up-list in the spelling panel and defaulted to the user's preferred language, so call this with care). */
  109.  
  110. - (const char *)language;
  111. - setLanguage:(const char *)language;
  112.  
  113. /* Allows programmatic setting of the misspelled word field. */
  114.  
  115. - setWordFieldValue:(const char *)aString;
  116.  
  117. @end
  118.